/*
 * Method chain length is perfectly readable due to the method names corresponding
 * to an easily discernable hierarchy.
 */
// $codepro.audit.disable methodChainLength
/*
 * toString method is not necessary for the game. Possible loss of 
 * precision is wanted in order to keep currency a whole number; 
 * does not affect game play.
 */
// $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString
// $codepro.audit.disable lossOfPrecisionInCast    
import javax.swing.JOptionPane;

/**
 * A class that affects market prices based on an event.
 * 
 * @author John J Storey
 * @version 5
 */
public class PlanetEvent { 
	/**
	 * Index for the planet being accessed.
	 */
    protected int index = 0;
    
    /**
     * Model for the game.
     */
    protected Model model = null;
    
    /**
     * Main GUI for the game.
     */
    protected View view = null;
    
    /**
     * Basic constructor.
     * 
     * @param model
     * @param view
     * @param i
     * @param index
     */
	public PlanetEvent(Model model, View view, int i, int index){
		this.index = index;
		this.model = model;
		this.view = view;
		run(i);
	}
	
	/**
	 * Method that runs the event.
	 * 
	 * @param i - the event to run
	 */
	private void run(int i) {
		JOptionPane.showMessageDialog(view, GoodsInfo.Ie[i]);
		Goods good = model.getUniverse().getPlanet(index).getMarket().getGoodsArray()[i]; // $codepro.audit.disable variableShouldBeFinal 
		good.setPrice((int) (good.getPrice() * 1.5));
		model.getUniverse().getPlanet(index).setNews(i);
	}
	
}